
 abstract class Ab {
   protected double income;

    //抽象方法
   public abstract double getTax(); 

}


//执行入口
class  Main{
    
    public static void main(String[] args){

        Ab[] incomes = {
            new Publ(2000),
            new Pub2(5000),
        };


        //调用getTatolTax
        getTatolTax(incomes);
    }



    //获取总的税
    public static  void getTatolTax(Ab... incomes){
        
        double total = 0;
        for(Ab income : incomes){
            total += income.getTax();
        }
        System.out.println(total);
    }
}


//继承Ab的具体子类
 class Publ extends Ab{

    public Publ(double income){
        this.income = income;
    }
    
    @Override
    public double getTax(){
        return income*0.1;
    }
}


//继承抽象类Ab的 具体子类
class Pub2 extends Ab{
 
     public Pub2(double income){
         this.income = income;
     }
     
     @Override
     public double getTax(){
         return income*0.2;
     }
 }
 